$(function(){
	$("#cancleBut").click(function(){
		parent.$('#dlg').window('close');
		parent.$(document.body).remove()
	});
	var codelength=$('#title').width();
	$('#price').validatebox({
		required: true,
	    tipPosition:'top',
	    deltaX:codelength/4,
	    validType: 'intOrFloat',
	});
	$('#levelname').combobox({
		 url:'/regionlevel/getCombobox',
		 valueField:'id',
		 textField:'text',
		 onSelect:function(record){
			 $("#levelid").val(record.id);
		 }
	});
	$('#modelname').combobox({
		 url:'/model/getCombobox',
		 valueField:'id',
		 textField:'text',
		 onSelect:function(record){
			 $("#modelid").val(record.id);
		 }
	});
	$('#remark').validatebox({
	    required: false,
	    tipPosition:'top',
	    validType: {maxLength:[255]},
	    deltaX:codelength/4
	});
	//提交表单
	$("#submitBut").click(function(){
		if($("#levelid").val()==''||$("#levelid").val()==undefined){
			$.messager.alert('失败','城市等级不能为空','error');
			return;
		}
		if($("#modelid").val()==''||$("#modelid").val()==undefined){
			$.messager.alert('失败','设备类型不能为空','error');
			return;
		}
		$("#form").form('submit',{
			url:'/levelmodelprice/saveLevelModelPrice',
			onSubmit:function(){
		        return $(this).form('validate');
		    },
		    success:function(data){
		    	var jdata=$.parseJSON(data); 
		        if(jdata.code==200){
		        	$.messager.alert('成功','保存成功','info',function(){
		        		parent.$('#dlg').window('close');
		        		window.parent.refreshTab("返款设置");
		        	});
		        }
		        else{
		        	$.messager.alert('失败',jdata.msg,'error');
		        }
		    }
		});
	})
})